
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>初始化和销毁 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="switch.html" />
    
    
    <link rel="prev" href="import.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="import.html">
            
                <a href="import.html">
            
                    
                    如何导入
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3" data-path="init.html">
            
                <a href="init.html">
            
                    
                    初始化和销毁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="switch.html">
            
                <a href="switch.html">
            
                    
                    开关设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="others.html">
            
                <a href="others.html">
            
                    
                    其他方法
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >初始化和销毁</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x521D;&#x59CB;&#x5316;&#x548C;&#x9500;&#x6BC1;">&#x521D;&#x59CB;&#x5316;&#x548C;&#x9500;&#x6BC1;</h1>
<h2 id="scaleeventlistener&#x63A5;&#x53E3;">ScaleEventListener&#x63A5;&#x53E3;</h2>
<p>&#x521D;&#x59CB;&#x5316;&#x524D;&#x9700;&#x5148;&#x5B9E;&#x73B0;SDK&#x4E2D;&#x7684;ScaleEventListener&#x63A5;&#x53E3;</p>
<p>&#x4F8B;&#x5982;</p>
<pre><code>class ExampleListener:ScaleEventListener {
    override fun onInitSuccess() {
        Log.e(&quot;qn&quot;,&quot;&#x521D;&#x59CB;&#x5316;&#x6210;&#x529F;&quot;)
    }

    override fun onMeasuringWeightStart() {
        Log.e(&quot;qn&quot;,&quot;&#x5F00;&#x59CB;&#x79F0;&#x91CD;&quot;)
    }

    override fun onMeasureWeight(weight: Double) {
        Log.e(&quot;qn&quot;,&quot;&#x5B9E;&#x65F6;&#x91CD;&#x91CF; $weight&quot;)
    }

    override fun onMeasuringFatStart() {
        Log.e(&quot;qn&quot;,&quot;&#x5F00;&#x59CB;&#x6D4B;&#x8102;&quot;)
    }

    override fun onMeasuringComplete(weight: Double, encryptedString: String) {
        Log.e(&quot;qn&quot;,&quot;&#x4F53;&#x91CD; $weight  &#x52A0;&#x5BC6;&#x5B57;&#x7B26;&#x4E32; $encryptedString&quot;)
    }

    override fun onMeasuringFail() {
        Log.e(&quot;qn&quot;,&quot;&#x6D4B;&#x91CF;&#x5931;&#x8D25;&quot;)
    }

     override fun onHasNewVersionFirmware(versionName:String) {
        Log.e(&quot;qn&quot;,&quot;&#x6709;&#x65B0;&#x7684;&#x56FA;&#x4EF6;&#x7248;&#x672C; $versionName&quot;)
        QNScaleApi.downloadFirmware()
    }

    override fun onFirmwareDownloadProgress(soFarBytes: Long, totalBytes: Long) {
        Log.e(&quot;qn&quot;,&quot;&#x56FA;&#x4EF6;&#x4E0B;&#x8F7D;&#x8FDB;&#x5EA6; $soFarBytes $totalBytes&quot;)
    }

     override fun onFirmwareDownloadCompleted() {
        Log.e(&quot;qn&quot;,&quot;&#x56FA;&#x4EF6;&#x4E0B;&#x8F7D;&#x6210;&#x529F;&quot;)
        QNScaleApi.installFirmware()
    }

    override fun onFirmwareDownloadFail() {
        Log.e(&quot;qn&quot;,&quot;&#x56FA;&#x4EF6;&#x4E0B;&#x8F7D;&#x5931;&#x8D25;&quot;)
    }

    override fun onFirmwareInstallStatus(status: Int) {
        Log.e(&quot;qn&quot;, &quot;&#x56FA;&#x4EF6;&#x5B89;&#x88C5;&#x72B6;&#x6001;$status&quot;)

    }

}
</code></pre><ul>
<li><p>&#x56FA;&#x4EF6;&#x5B89;&#x88C5;&#x72B6;&#x6001;&#xFF1A; onFirmwareInstallStatus(status: Int)</p>
<pre><code>   * status 0&#x4E3A;&#x65E0;&#x9700;&#x5B89;&#x88C5;
   * status 1&#x5B89;&#x88C5;&#x6210;&#x529F;
   * status 2&#x5B89;&#x88C5;&#x5931;&#x8D25;
   * status 3&#x4E0D;&#x80FD;&#x5B89;&#x88C5;
</code></pre></li>
</ul>
<hr>
<h2 id="&#x521D;&#x59CB;&#x5316;sdk">&#x521D;&#x59CB;&#x5316;SDK</h2>
<p>&#x8BF7;&#x4F7F;&#x7528;Application&#x7684;context&#x521D;&#x59CB;&#x5316;SDK&#xFF0C;&#x907F;&#x514D;&#x4F20;&#x5165;&#x7684;context&#x751F;&#x547D;&#x5468;&#x671F;&#x7ED3;&#x675F;&#x5BFC;&#x81F4;SDK&#x62A5;&#x9519;</p>
<p>&#x5728;&#x81EA;&#x5B9A;&#x4E49;&#x7684;Application&#x4E2D;</p>
<pre><code>override fun onCreate() {
    super.onCreate()
    QNScaleApi.setScaleEventListener(ExampleListener())
    QNScaleApi.initSdk(this)
}
</code></pre><p>&#x6CE8;&#x610F;&#xFF1A;&#x5728;&#x8C03;&#x7528;initSdk&#x524D;&#x5FC5;&#x987B;&#x5148;&#x8C03;&#x7528;setScaleEventListener&#xFF0C;&#x5426;&#x5219;&#x4F1A;&#x629B;&#x51FA;NullScaleEventListenerException&#x5F02;&#x5E38;</p>
<hr>
<h2 id="&#x83B7;&#x53D6;scaledeviceinfo">&#x83B7;&#x53D6;ScaleDeviceInfo</h2>
<p>&#x5728;&#x521D;&#x59CB;&#x5316;&#x6210;&#x529F;&#xFF0C;&#x5373;&#x6536;&#x5230;onInitSuccess&#x56DE;&#x8C03;&#x540E;&#xFF0C;&#x5373;&#x53EF;&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x79E4;&#x7684;ScaleDeviceInfo</p>
<pre><code>QNScaleApi.getScaleDeviceInfo()
</code></pre><p>&#x5F00;&#x53D1;&#x8005;&#x9700;&#x8981;&#x5173;&#x6CE8;ScaleDeviceInfo&#x7684;&#x4E0B;&#x5217;&#x5C5E;&#x6027;</p>
<table>
<thead>
<tr>
<th style="text-align:center">&#x53D8;&#x91CF;&#x540D;</th>
<th style="text-align:center">&#x7C7B;&#x578B;</th>
<th style="text-align:center">&#x8BF4;&#x660E;  </th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">sn</td>
<td style="text-align:center">String</td>
<td style="text-align:center">&#x5E8F;&#x5217;&#x53F7;</td>
</tr>
<tr>
<td style="text-align:center">hasCompleteProduction</td>
<td style="text-align:center">Boolean</td>
<td style="text-align:center">&#x662F;&#x5426;&#x5DF2;&#x5B8C;&#x6210;&#x751F;&#x4EA7;</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="&#x9500;&#x6BC1;">&#x9500;&#x6BC1;</h2>
<p>&#x9000;&#x51FA;App&#x65F6;&#xFF0C;&#x5728;&#x6700;&#x7EC8;&#x7ED3;&#x675F;&#x7684;Activity&#x4E2D;&#x8C03;&#x7528;</p>
<pre><code>override fun onDestroy() {
    super.onDestroy()
    QNScaleApi.destroy()
}
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="import.html" class="navigation navigation-prev " aria-label="Previous page: 如何导入">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="switch.html" class="navigation navigation-next " aria-label="Next page: 开关设置">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"初始化和销毁","level":"1.3","depth":1,"next":{"title":"开关设置","level":"1.4","depth":1,"path":"component/switch.md","ref":"component/switch.md","articles":[]},"previous":{"title":"如何导入","level":"1.2","depth":1,"path":"component/import.md","ref":"component/import.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"component/init.md","mtime":"2020-11-23T08:21:42.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-11-23T09:04:17.579Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

